using System.Text.Json.Serialization;

namespace Services.Error.Domain.Entities;
public class ErrorItem
{
    public string Id { get; private set; }
    public string? StackTrace { get; private set; }
    public string? Message { get; private set; }
    public DateTime OccurTime { get; private set; }

    [JsonConstructor]
    private ErrorItem(string id,string message, DateTime occurTime, string stackTrace)
    {
        Id = id;
        Message = message;
        OccurTime = occurTime;
        StackTrace = stackTrace;
    }
    private ErrorItem()
    {
        Id = Guid.NewGuid().ToString();
    }
    public static ErrorItem Create(string message, DateTime occurTime, string stackTrace)
    {
        return new ErrorItem { Message = message, OccurTime = occurTime, StackTrace = stackTrace };
    }
    public override string ToString()
    {
        return $"Id: {Id}, Message: {Message}, OccurTime: {OccurTime}, StackTrace: {StackTrace}";
    }
}